﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Acme.BookStore2.Migrations
{
    public partial class vehicle_repairattachfiles : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AttachFile_AppVehicleInspectionRecord_VehicleInspectionRecor~",
                table: "AttachFile");

            migrationBuilder.DropIndex(
                name: "IX_AttachFile_VehicleInspectionRecordId",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "CreationTime",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "CreatorId",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "DeleterId",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "DeletionTime",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "IsDeleted",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "LastModificationTime",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "LastModifierId",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "Name",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "ProviderKey",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "ProviderName",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "Remark",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "VehicleInspectionRecordId",
                table: "AttachFile");

            migrationBuilder.AlterColumn<int>(
                name: "Id",
                table: "AttachFile",
                nullable: false,
                oldClrType: typeof(Guid),
                oldType: "char(36)")
                .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

            migrationBuilder.AddColumn<Guid>(
                name: "OwnerId",
                table: "AttachFile",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.CreateIndex(
                name: "IX_AttachFile_OwnerId",
                table: "AttachFile",
                column: "OwnerId");

            migrationBuilder.AddForeignKey(
                name: "FK_AttachFile_AppVehicleRepairRecord_OwnerId",
                table: "AttachFile",
                column: "OwnerId",
                principalTable: "AppVehicleRepairRecord",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AttachFile_AppVehicleRepairRecord_OwnerId",
                table: "AttachFile");

            migrationBuilder.DropIndex(
                name: "IX_AttachFile_OwnerId",
                table: "AttachFile");

            migrationBuilder.DropColumn(
                name: "OwnerId",
                table: "AttachFile");

            migrationBuilder.AlterColumn<Guid>(
                name: "Id",
                table: "AttachFile",
                type: "char(36)",
                nullable: false,
                oldClrType: typeof(int))
                .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

            migrationBuilder.AddColumn<DateTime>(
                name: "CreationTime",
                table: "AttachFile",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<Guid>(
                name: "CreatorId",
                table: "AttachFile",
                type: "char(36)",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "DeleterId",
                table: "AttachFile",
                type: "char(36)",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "DeletionTime",
                table: "AttachFile",
                type: "datetime(6)",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsDeleted",
                table: "AttachFile",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<DateTime>(
                name: "LastModificationTime",
                table: "AttachFile",
                type: "datetime(6)",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "LastModifierId",
                table: "AttachFile",
                type: "char(36)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Name",
                table: "AttachFile",
                type: "longtext CHARACTER SET utf8mb4",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "ProviderKey",
                table: "AttachFile",
                type: "longtext CHARACTER SET utf8mb4",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "ProviderName",
                table: "AttachFile",
                type: "longtext CHARACTER SET utf8mb4",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Remark",
                table: "AttachFile",
                type: "longtext CHARACTER SET utf8mb4",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "VehicleInspectionRecordId",
                table: "AttachFile",
                type: "char(36)",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_AttachFile_VehicleInspectionRecordId",
                table: "AttachFile",
                column: "VehicleInspectionRecordId");

            migrationBuilder.AddForeignKey(
                name: "FK_AttachFile_AppVehicleInspectionRecord_VehicleInspectionRecor~",
                table: "AttachFile",
                column: "VehicleInspectionRecordId",
                principalTable: "AppVehicleInspectionRecord",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
